package source.home;



import java.io.InputStream;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;

public class store extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.store);
    }
    public void storemessage(View button)
    {
    	String server = "http://smsever4guni.appspot.com/";
    	///////////code : take data from text views///////
    	EditText messagetext = (EditText) findViewById(R.id.messagetext);
    	String username = fetchshp("username").toString();
    	
    	String message = messagetext.getText().toString().replaceAll(" ", "___");
    	//////////code : http client code///////

    	InputStream is = null;
    	String result="";
    	String url = server+"storemessage?username="+username.toString()+"&message="+message;
    	try
		{
        HttpClient httpclient = new DefaultHttpClient();
      
        HttpGet HttpGet = new HttpGet(url);
        
        HttpResponse response = httpclient.execute(HttpGet);
        HttpEntity entity = response.getEntity();
        is = entity.getContent();
        
////////////////Shared Preference memory is created///////////
       //	createshp("username",username.getText().toString());
    	System.out.println("excrypted Message"+message);
    	
            System.out.println(username.toString());
            
            
        
        
		}
		
    	catch(Exception e)
    	{
        Log.e("log_tag", "Error in http connection "+e.toString());
        System.out.println("donga dorikindhi");
        
       	}

    	
    	
    }
    public String fetchshp(String key)
    {
    	
    	//String value = null;
    	  SharedPreferences sharedPreferences = getSharedPreferences(key,MODE_PRIVATE);
    	  String value = sharedPreferences.getString(key, "not available");
    	return value;
    }
}